<template>
    <div>
        <el-form ref="setNameFormRef" :model="setNameForm" label-width="180px" >
            <el-form-item label="要修改的名称">
                <el-radio-group v-model="setNameType">
                    <el-radio label="signName">签约名</el-radio>
                    <el-radio label="showName">展示名</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="原签约名：" v-if="setNameType==='signName'">
                <span>{{oldSignName}}</span>
            </el-form-item>
            <el-form-item label="签约名：" v-if="setNameType==='signName'">
                <el-input v-model="setNameForm.signName"></el-input>
            </el-form-item>
            <el-form-item label="营业执照号：" v-if="setNameType==='signName'">
                <el-input v-model="setNameForm.businessLicense"></el-input>
            </el-form-item>
            <el-form-item label="原展示名：" v-if="setNameType==='showName'">
                <span>{{oldShowName}}</span>
            </el-form-item>
            <el-form-item label="展示名：" v-if="setNameType==='showName'">
                <el-input v-model="setNameForm.showName"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="confirmOpen(setNameForm)">确认修改</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
export default {
    props: {
        id: Number,
        oldSignName:String,
        oldShowName:String
    },
    data() {
        return {
            setNameType:'signName',
            setNameForm: {},
        }
    },
    created() {
    },
    methods: {
        confirmOpen(form) {
            let _this=this;
            if(this.setNameType=="signName"){
                if(form.signName==''||form.signName==undefined||form.businessLicense==''||form.businessLicense==undefined){
                    this.$message.error('请填写完整数据');
                    return
                }
            }else{
                if(form.showName==''||form.showName==undefined){
                    this.$message.error('请填写完整数据');
                    return
                }
            }
            this.$axios({
                url: '/admin/channel/other',
                data: {
                    type: 1,
                    userID: _this.id,
                    genre: 6,
                    signName:_this.setNameType=="signName"?form.signName:null,
                    businessLicense:_this.setNameType=="signName"?form.businessLicense:null,
                    showName:_this.setNameType=="signName"?null:form.showName
                },
                success(res) {
                    if(res.data.code==200){
                        _this.$emit("getChannelIntoInfo");
                        _this.$message({
                            message:res.data.msg,
                            type:'success'
                        });
                        _this.setNameForm.showName='';
                    }else{
                        _this.$message.error(res.data.msg);
                    }
                }
            });

        }
    }
}
</script>
<style scoped>
.el-input {
    width: 200px;
}
</style>